<template>
  <view class="defect-log-create">
	<view>
		<span class="user">[{{log.createByName}}]</span>
		<span class="state">{{ $i18n.t('defect.assigned-to') }}</span>
		<view v-if="log.receiveByList && log.receiveByList.length>1">
		  <span class="user">[{{head}}]</span>
		  <span class="state">{{$i18n.t('head-up')}},</span>
		  <span class="user">[{{assistant}}]</span>
		  <span class="state orange">{{$i18n.t('assist')}}</span>
		</view>
		<span v-else-if="log.receiveByList" class="user">[{{head}}]</span>
	</view>
	<view>
		<text class="cat2bug-list-item-content">{{createTime(log)}}</text>
	</view>
	<view v-if="showDescribe && log.defectLogDescribe">
	  <text class="cat2bug-list-item-content">{{$i18n.t('describe')}}:</text>
	  <text class="cat2bug-list-item-content">{{log.defectLogDescribe}}</text>
	</view>
  </view>
</template>

<script>
import {parseTime} from "@/utils/ruoyi"
export default {
  name: "ASSIGN",
  props:{
    /** 日志对象 */
    log: {
      type: Object,
      default: ()=>{}
    },
    /** 是否显示描述字段 */
    showDescribe: {
    	type: Boolean,
    	default: true
    }
  },
  computed: {
    head: function () {
      return this.log.receiveByList[0].nickName;
    },
    assistant: function () {
      return this.log.receiveByList.filter((l,i)=>i!=0).map(l=>l.nickName).join(',');
    },
	createTime: function() {
		return function(log) {
			return parseTime(log.createTime, '{y}-{m}-{d} {h}:{i}:{s}')
		}
	}
  },
}
</script>

<style lang="scss" scoped>
  .defect-log-create {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: wrap;
    font-size: 14px;
    span {
      padding-left: 2px;
      padding-right: 2px;
    }
    .user {
      font-weight: 500;
    }
    .state {
      font-size: 14px;
      color: #409EFF;
    }
    .orange {
      color: rgb(255, 186, 0);
    }
  }
</style>
